Use the Loop
statement to set up a series of statements that run repeatedly while a specific condition remains true. A common use of looping is to use a variable as a counter and perform an action while the counter is less than a specified value. At the end of each loop, you increment the counter. To use the Loop
statement effectively, you should be familiar with creating expressions that evaluate conditions. See Writing expressions.
For every Loop
statement, an End Loop
statement marks the end of the statements that run when the condition remains. Upon reaching the End Loop
statement, Flash starts the loop over by testing the condition. If the condition is false or equal to zero, Flash skips to the first statement following End Loop
.
For example, these statements form a sample loop that runs ten times. Each time the loop runs, the Index variable is increased by 1. When Index equals 11, the expression Index <= 10
is false, so Flash skips past the loop to any subsequent statements.
Set Variable: "Index" = 1 Loop While (Index <= 10) Set Property ("target_item", Y position) = 150 Set Variable: "Index" = Index +1 End Loop
The screen is not updated until the loop finishes.